/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Consumer.h"
#include "Galaxy.h"

#include <mediator/Event.h>
#include <input/MediatorTypes.h>

namespace galaxy {

    Consumer::Consumer(void)
    {
        m_Galaxy = 0L;
    }

    Consumer::~Consumer(void)
    {
        m_Galaxy = 0L;
    }

    void Consumer::handleEvent (mediator::Event& event) {
        if (event == mediator::Identifier(mediator::CATEGORY_INPUT,MODULE_TYPE_INPUT_KEY,
            MODULE_SUBTYPE_INPUT_KEYRELEASE)) {
                input::KeyEvent& keyevent = dynamic_cast<input::KeyEvent&>(event);

                if (keyevent.m_KeyAction == input::INPUT_KEYACTION_EXIT) {
                    m_Galaxy->signalTerminateGame();
                }
        }
    }

} // namespace galaxy
